import request from '@/utils/request';

import axios from 'axios';

export function checkUploaded() {
    return request({
        url: '/first-loan/checkUploaded.do',
        method: 'post'
    });
}

export function getFirstLoanTemp(pageInfo) {
    return request({
        url: '/first-loan/getFirstLoanTemp.do',
        method: 'post',
        data: pageInfo
    });
}

export function getFormatErrorCount() {
    return request({
        url: '/first-loan/getFormatErrorCount.do',
        method: 'post'
    });
}

export function getTempDataCount() {
    return request({
        url: '/first-loan/getTempDataCount.do',
        method: 'post'
    });
}

export function clearTempData() {
    return request({
        url: '/first-loan/clearTempData.do',
        method: 'delete'
    });
}

export function compareToDatabase() {
    return request({
        url: '/first-loan/compareToDatabase.do',
        method: 'post'
    });
}

export function checkMergeable() {
    return request({
        url: '/first-loan/checkMergeable.do',
        method: 'post'
    });
}

export function deleteTemp(tempId) {
    return request({
        url: `/first-loan/deleteTemp.do/${tempId}`,
        method: 'delete'
    });
}

export function merge() {
    return request({
        url: '/first-loan/merge.do',
        method: 'post'
    });
}

/**
 * 对首贷户相关操作
 */

export function getFirstLoanList(firstLoanQuery) {
    return request({
        url: '/first-loan/getFirstLoanList.do',
        method: 'post',
        data: firstLoanQuery
    })
}

export function deleteFirstLoanById(id) {
    return request({
        url: `/first-loan/deleteFirstLoanById.do/${id}`,
        method: 'delete'
    })
}

export function deleteFirstLoanByMonth(deleteInfo) {
    return request({
        url: `/first-loan/deleteFirstLoanByMonth.do`,
        method: 'delete',
        data: deleteInfo
    })
}

export function downloadFirstLoan(param) {
    return axios({
        baseURL: process.env.BASE_URL,
        method: 'post',
        url: `/first-loan/downloadFirstLoan.do`,
        responseType: 'blob',
        data: param
    });
}

/**
 * -----------------对首贷户相关操作结束
 */


/**
 * 对首贷户校验结果相关操作
 */
export function getFirstLoanResultList(firstLoanReslutQuery) {
    return request({
        url: '/first-loan/getFirstLoanResultList.do',
        method: 'post',
        data: firstLoanReslutQuery
    })
}

export function deleteFirstLoanResultByMonth(month) {
    return request({
        url: `/first-loan/deleteFirstLoanResultByMonth.do/${month}`,
        method: 'delete',
    })
}

export function downloadResult(downloadInfo) {
    return axios({
        baseURL: process.env.BASE_URL,
        method: 'post',
        url: `/first-loan/downloadResult.do`,
        responseType: 'blob',
        data: downloadInfo
    });
}

/**
 * 
 * -----------------------对首贷户校验结果相关操作
 */

export function getFirstLoanStatistics1(month) {
    return request({
        url: `/first-loan/getFirstLoanStatistics1.do/${month}`,
        method: 'post'
    })
}

export function getFirstLoanStatistics2(month) {
    return request({
        url: `/first-loan/getFirstLoanStatistics2.do/${month}`,
        method: 'post'
    })
}

export function getFirstLoanStatistics3(month) {
    return request({
        url: `/first-loan/getFirstLoanStatistics3.do/${month}`,
        method: 'post'
    })
}
export function getFirstLoanStatistics5(month) {
    return request({
        url: `/first-loan/getFirstLoanStatistics5.do/${month}`,
        method: 'post'
    })
}

export function getFirstLoanOrgCategoryList() {
    return request({
        url: '/first-loan/getOrgCategoryList.do',
        method: 'post'
    });
}

export function getOrgCategoryDetailList(categoryId) {
    return request({
        url: `/first-loan/getOrgCategoryDetailList.do/${categoryId}`,
        method: 'post'
    });
}

export function getOrgCategoryEditList(categoryId) {
    return request({
        url: `/first-loan/getOrgCategoryEditList.do/${categoryId}`,
        method: 'post'
    });
}

export function addOrgCategoryLink(categoryInfo) {
    return request({
        url: '/first-loan/addOrgCategoryLink.do',
        method: 'post',
        data: categoryInfo
    })
}

export function removeOrgCategoryLink(categoryInfo) {
    return request({
        url: '/first-loan/removeOrgCategoryLink.do',
        method: 'post',
        data: categoryInfo
    })
}

export function deleteOrgCategory(categoryId) {
    return request({
        url: `/first-loan/deleteOrgCategory.do/${categoryId}`,
        method: 'post',
    })
}

export function addOrgCategory(name) {
    return request({
        url: `/first-loan/addOrgCategory.do/${name}`,
        method: 'post'
    })
}

export function upwardOrgCategory(categoryId) {
    return request({
        url: `/first-loan/upwardOrgCategory.do/${categoryId}`,
        method: 'post'
    })
}

export function downwardOrgCategory(categoryId) {
    return request({
        url: `/first-loan/downwardOrgCategory.do/${categoryId}`,
        method: 'post'
    })
}

/**
 * 获取图表数据
 */

export function getStatistics1ChartData() {
    return request({
        url: `/first-loan/getStatistics1ChartData.do`,
        method: 'post'
    })
}

export function getBankChartData() {
    return request({
        url: `/first-loan/getBankChartData.do`,
        method: 'post'
    })
}

export function getChart1Data(query){
    return request({
        url: `/first-loan/getChart1Data.do`,
        method: 'post',
        data: query
    })
}

export function getChart2Data(query){
    return request({
        url: `/first-loan/getChart2Data.do`,
        method: 'post',
        data: query
    })
}

export function getChart3Data(query){
    return request({
        url: `/first-loan/getChart3Data.do`,
        method: 'post',
        data: query
    })
}

export function getChart4Data(query){
    return request({
        url: `/first-loan/getChart4Data.do`,
        method: 'post',
        data: query
    })
}

/**
 * 获取图表数据----------------------------
 */

export function downloadReport(month) {
    return axios({
        baseURL: process.env.BASE_URL,
        method: 'get',
        url: `/first-loan/downloadReport.do/${month}`,
        responseType: 'blob',
    });
}


/**
 * 对首贷户机构相关操作
 */

export function getAllFirstLoanOrgList() {
    return request({
        url: `/first-loan/getAllFirstLoanOrgList.do`,
        method: 'get'
    })
}

/**
 * ----------对首贷户机构相关操作结束
 */

/***
 * 对首贷户数据库相关操作
 */
export function getFirstLoanBaseList(baseQuery) {
    return request({
        url: `/first-loan/getFirstLoanBaseList.do`,
        method: 'post',
        data: baseQuery
    })
}
export function deleteFirstLoanBaseItem(id) {
    return request({
        url: `/first-loan/deleteFirstLoanBaseItem.do/${id}`,
        method: 'delete'
    })
}

export function getFirstLoanBaseSource() {
    return request({
        url: `/first-loan/getFirstLoanBaseSource.do`,
        method: 'get'
    })
}

export function getFirstLoanBaseSourceDateList() {
    return request({
        url: `/first-loan/getFirstLoanBaseSourceDateList.do`,
        method: 'get'
    })
}

export function deleteFirstLoanBaseByReportDate(param) {
    return request({
        url: `/first-loan/deleteFirstLoanBaseByReportDate.do`,
        method: 'delete',
        data: param
    })
}

export function downloadFirstLoanBase(param) {
    return axios({
        baseURL: process.env.BASE_URL,
        method: 'post',
        url: `/first-loan/downloadFirstLoanBase.do`,
        responseType: 'blob',
        data: param
    });
}

/**
 * 数贷户数据库相关操作结束---------------------------
 */